home *** CD-ROM | disk | FTP | other *** search
- Path: castle.nando.net!news
- From: actuary@nando.net (Bill McCarthy)
- Newsgroups: comp.lang.c
- Subject: Re: Rand() Function
- Date: 26 Mar 1996 21:16:08 GMT
- Organization: Nando.net Public Access
- Message-ID: <4j9mqo$c0h@castle.nando.net>
- References: <4iqltj$40g@news1.sympatico.ca>
- Reply-To: actuary@nando.net (Bill McCarthy)
- NNTP-Posting-Host: grail1819.nando.net
- X-Newsreader: IBM NewsReader/2 v1.2
-
- In <4iqltj$40g@news1.sympatico.ca>, Gisele Swinson <gisele.swinson@sympatico.ca> writes:
- >How do I get a random number from a "SET" of numbers.
- >
- >e.g.
- >
- > I want a random number from this set:
- >
- > 2, 4, 6, 8, 10
- >
- >It seems so simple but I can't find anything in my text how to do this.
-
- It is! See the FAQ. It explains how to write a function to to return a
- "random" number from 0 to n-1. Once you have a number from 0 to 4,
- add 1, then double the sum.
-
- Bill McCarthy
- actuary@nando.net
- Wendell, NC USA
-
-